<?php

/**
 * Created by PhpStorm.
 * User: evan
 * Date: 16/9/19
 * Time: 上午1:09
 */
class Base extends MY_Api_Controller
{
    /**
     * 列表页
     */
    public function index()
    {
        $page  = (int)$this->input->get_post('page');
        $limit = (int)$this->input->get_post('limit');


        $this->load->service('voice/service_voice_base');
        $data = $this->service_voice_base->index($page, $limit);


        foreach ($data['data'] as $k => $v)
        {
            //unset($data['data'][$k]['uid']);
            //unset($data['data'][$k]['uname']);
            unset($data['data'][$k]['ip']);
        }


        $this->json_output($data['data'], $data['status']);
    }


    /**
     * 创建呼声
     */
    public function create()
    {
        $uid     = $this->uid;
        $pic     = (int)$this->input->get_post('pic');
        $title   = trim($this->input->get_post('title'));
        $summary = trim($this->input->get_post('summary'));


        $this->load->service('voice/service_voice_base');
        $data = $this->service_voice_base->create($uid, $pic, $title, $summary);


        unset($data['data']['ip']);


        $this->json_output($data['data'], $data['status']);
    }
}